import {fhirSearchApi,fhirHistoryApi,fhirDeleteApi} from "../../api/modules/fhirApi";
import {createLabReportApi, updateLabReportApi} from "../../api/modules/labReportApi";

export default {
  state: {
    labReportList: []
  },
  mutations: {
    setLabReportList(state, data) {
      state.labReportList = data;
    }
  },
  actions: {
    getLabReportList({commit, rootState}, params) {
      return fhirSearchApi(params).then(res => {
        console.log(res)
        commit('setLabReportList', res.data.entry ? res.data.entry : [{resource:res.data}])
      }).catch(res =>{
        commit('setLabReportList',[]);
      })
    },
    getHistoryLabReportList({commit, rootState}, params) {
      return fhirHistoryApi(params).then(res => {
        commit('setLabReportList', res.data.entry ? res.data.entry : [{resource:res.data}])
      })
    },
    updateLabReport({commit, rootState}, params) {
      return updateLabReportApi(params);
    },
    createLabReport({commit, rootState}, params) {
      return createLabReportApi(params);
    },
    deleteLabReport({commit, rootState}, params) {
      return fhirDeleteApi(params);
    }
  }
}
